package com.chenchao.thread;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/17 20:45
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.javathread.Test15.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * 守护线程
 */
public class Test15 {
    public static void main(String[] args) {
        Thread thread = new Thread(new God());
        Thread thread1 = new Thread(new P());
        thread.setDaemon(true);
        //默认都是false,设成true后，从用户线程变成守护线程
        thread.start();
        thread1.start();
    }
}
class God implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("我是上帝，守护世间和平");
        }
    }
}
class P implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i <100; i++) {
            System.out.println("我是人，人生苦短，及时行乐");
        }
        System.out.println("我他娘的竟然要挂了");
    }
}